﻿@model ProductDetailsModel
@using Nop.Core
@using Nop.Core.Domain.Seo;
@using Nop.Core.Infrastructure;
@using Nop.Services.Localization;
@using Nop.Web.Models.Catalog;
@{
    Layout = "~/Views/Shared/_ColumnsTwo.cshtml";

    //title, meta
    Html.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
    Html.AddMetaDescriptionParts(Model.MetaDescription);
    Html.AddMetaKeywordParts(Model.MetaKeywords);

    var seoSettings = EngineContext.Current.Resolve<SeoSettings>();
    
    //canonical URL
    if (seoSettings.CanonicalUrlsEnabled)
    {
        var productUrl = Url.RouteUrl("Product", new { SeName = Model.SeName }, this.Request.Url.Scheme);
        Html.AddCanonicalUrlParts(productUrl);
    }

    //open graph META tags
    if (seoSettings.OpenGraphMetaTags)
    {
        var storeName = EngineContext.Current.Resolve<IStoreContext>().CurrentStore.GetLocalized(x => x.Name);
        Html.AddHeadCustomParts("<meta property=\"og:type\" content=\"product\" />");
        Html.AddHeadCustomParts("<meta property=\"og:title\" content=\"" + Html.Encode(Model.Name) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"og:description\" content=\"" + Html.Encode(Model.MetaDescription) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"og:image\" content=\"" + Model.DefaultPictureModel.ImageUrl + "\" />");
        Html.AddHeadCustomParts("<meta property=\"og:url\" content=\"" + Request.Url.AbsoluteUri + "\" />");
        Html.AddHeadCustomParts("<meta property=\"og:site_name\" content=\"" + Html.Encode(storeName) + "\" />");
    }

    //Twitter META tags
    if (seoSettings.TwitterMetaTags)
    {
        var storeName = EngineContext.Current.Resolve<IStoreContext>().CurrentStore.GetLocalized(x => x.Name);
        Html.AddHeadCustomParts("<meta property=\"twitter:card\" content=\"summary\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:site\" content=\"" + Html.Encode(storeName) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:title\" content=\"" + Html.Encode(Model.Name) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:description\" content=\"" + Html.Encode(Model.MetaDescription) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:image\" content=\"" + Model.DefaultPictureModel.ImageUrl + "\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:url\" content=\"" + Request.Url.AbsoluteUri + "\" />");
    }
}
<!--product breadcrumb-->
@Html.Partial("_ProductBreadcrumb", Model.Breadcrumb)
@Html.Widget("productdetails_after_breadcrumb", Model.Id)
<div class="page product-details-page">
    <div class="page-body">
        @Html.Widget("productdetails_top", Model.Id)
        @using (Html.BeginRouteForm("Product", new { SeName = Model.SeName }, FormMethod.Post, new { id = "product-details-form" }))
        {
            <div itemscope itemtype="http://schema.org/Product" data-productid="@Model.Id">
                <div class="product-essential">
                    @Html.Widget("productdetails_before_pictures", Model.Id)
                    <!--product pictures-->
                    @Html.Partial("_ProductDetailsPictures", Model)
                    @Html.Widget("productdetails_after_pictures", Model.Id)
                    <div class="overview">
                        <div class="product-name">
                            <h1 itemprop="name">
                                @Model.Name
                            </h1>
                        </div>
                        @if (!String.IsNullOrEmpty(Model.ShortDescription))
                        {
                            <div class="short-description">
                                @Html.Raw(Model.ShortDescription)
                            </div>
                        }
                        @Html.Widget("productdetails_overview_top", Model.Id)
                        <!--product manufacturers-->
                        @Html.Partial("_ProductManufacturers", Model.ProductManufacturers)
                        <!--product reviews-->
                        @Html.Partial("_ProductReviewOverview", Model.ProductReviewOverview)
                        @Html.Partial("_ProductEmailAFriendButton", Model)
                        @Html.Partial("_CompareProductsButton", Model)
                        @Html.Partial("_ShareButton", Model)
                        @Html.Widget("productdetails_overview_bottom", Model.Id)
                    </div>
                    @if (!String.IsNullOrEmpty(Model.FullDescription))
                    {
                        <div class="full-description" itemprop="description">
                            @Html.Raw(Model.FullDescription)
                        </div>
                    }
                </div>
                @Html.Widget("productdetails_before_collateral", Model.Id)
                <div class="product-collateral">
                    <!--associated products-->
                    <div class="product-variant-list">
                        @foreach (var variant in Model.AssociatedProducts)
                        {
                            <div class="product-variant-line" data-productid="@variant.Id">
                                @if (!String.IsNullOrWhiteSpace(variant.DefaultPictureModel.ImageUrl))
                                {
                                    <div class="variant-picture">
                                        <img alt="@variant.DefaultPictureModel.AlternateText" src="@variant.DefaultPictureModel.ImageUrl"
                                             title="@variant.DefaultPictureModel.Title" id="main-product-img-@variant.Id" />
                                    </div>
                                }
                                <div class="variant-overview">
                                    @if (!String.IsNullOrWhiteSpace(variant.Name))
                                    {
                                        <div class="variant-name">
                                            @variant.Name
                                        </div>
                                    }
                                    @if (!String.IsNullOrWhiteSpace(variant.ShortDescription))
                                    {
                                        <div class="variant-description">
                                            @Html.Raw(variant.ShortDescription)
                                        </div>
                                    }
                                    @Html.Partial("_DownloadSample", variant)
                                    @Html.Partial("_ProductTierPrices", variant.TierPrices)
                                    @{
                                        var dataDictAttributes = new ViewDataDictionary();
                                        dataDictAttributes.TemplateInfo.HtmlFieldPrefix = string.Format("attributes_{0}", variant.Id);
                                        @Html.Partial("_ProductAttributes", variant.ProductAttributes, dataDictAttributes)                  
                                    }
                                    <!--product SKU, manufacturer part number, stock info-->
                                    @Html.Partial("_SKU_Man_Stock", variant)
                                    <!--Back in stock subscription-->
                                    @Html.Partial("_BackInStockSubscription", variant)
                                    @{
                                        var dataDictGiftCard = new ViewDataDictionary();
                                        dataDictGiftCard.TemplateInfo.HtmlFieldPrefix = string.Format("giftcard_{0}", variant.Id);
                                        @Html.Partial("_GiftCardInfo", variant.GiftCard, dataDictGiftCard)
                                    }
                                    @{
                                        var dataDictRental = new ViewDataDictionary();
                                        dataDictRental.TemplateInfo.HtmlFieldPrefix = string.Format("rental_{0}", variant.Id);
                                        @Html.Partial("_RentalInfo", variant, dataDictRental)
                                    }
                                    @{
                                        var dataDictPrice = new ViewDataDictionary();
                                        dataDictPrice.TemplateInfo.HtmlFieldPrefix = string.Format("price_{0}", variant.Id);
                                        @Html.Partial("_ProductPrice", variant.ProductPrice, dataDictPrice)
                                    }
                                    @{
                                        var dataDictAddToCart = new ViewDataDictionary();
                                        dataDictAddToCart.TemplateInfo.HtmlFieldPrefix = string.Format("addtocart_{0}", variant.Id);
                                        @Html.Partial("_AddToCart", variant.AddToCart, dataDictAddToCart)
                                    }
                                </div>
                            </div>
                        }
                        @if (Model.AssociatedProducts.Count == 0)
                        {
                            <div class="no-associated-products">
                                @T("Products.NoAssociatedProducts")
                            </div>
                        }
                    </div>
                    @Html.Partial("_ProductSpecifications", Model.ProductSpecifications)
                    @Html.Partial("_ProductTags", Model.ProductTags)
                    @*we do not display "also purchased" for grouped products
                    @Html.Action("ProductsAlsoPurchased", "Product", new { productId = Model.Id })*@
                    @Html.Action("RelatedProducts", "Product", new { productId = Model.Id })
                </div>
            </div>
        }
        @Html.Widget("productdetails_bottom", Model.Id)
    </div>
</div>
